var rootview = ui("$");
var app = sm("do_App");
var page = sm("do_Page");
var nf = sm("do_Notification");
var common = require("common");
var openHelper = require("helper/open");
var shareHelper = require("helper/share");
var http = require("helper/http");
var mallUrl = require("url/mall");
var do_ALayout_title = ui("do_ALayout_title");
var productName = ui("productName");

var do_GridView_1 = ui("do_GridView_1");


rootview.setMapping({
    "productName.text" : "specName",
    "lablePrice.text" : "price",
    "lableStock.text" : "stock",
    "do_ALayout_title.tag" : "productId", //商品id
    "productName.tag" : "id"
});

rootview.on("dataRefreshed", function(){

});

//删除规格
ui("btnOnSell").on("touch", function(data, e) {
	var specId = productName.tag;
	if(specId){
		http.post(mallUrl.url.product.deleteSpec, {id: specId}, function(data) {
			nf.toast("已删除");
			page.fire("mall_product_spec_refresh");
		});
	}
})

//编辑
ui("btnEdit").on("touch", function(data, e) {
	var productId = do_ALayout_title.tag;
	var specId = productName.tag;
	if(productId && specId){
		openHelper.open("source://view/qshop/manage/product/editSpec.ui",{productId:productId,specId:specId});
	}
})